package com.g4.shoppingsingle.controller;


import com.g4.shoppingsingle.model.DdOrderInfo;
import com.g4.shoppingsingle.service.IDdOrderInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.annotation.AuthenticationPrincipal;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 * 订单表 前端控制器
 * </p>
 *
 * @author admin
 * @since 2021-10-27
 */
@RestController
@RequestMapping("/shoppingsingle/ddOrderInfo")
public class DdOrderInfoController {

    @Autowired
    private IDdOrderInfoService ddOrderInfoService;

    /**
     * 获取当前登录用户的订单
     * @param user
     * @return
     */
    @GetMapping("/dingdanzhongxin")
    public List<DdOrderInfo> orders( @AuthenticationPrincipal UserDetails user ){
        List<DdOrderInfo> orders=ddOrderInfoService.getOrders(user.getUsername());
        System.out.println("我的订单:"+orders);
        return orders;
    }


}
